﻿using System.Collections.Generic;
using LightContracts;

namespace LightContractsExamples
{
	public class TextStorage
	{
		private IDictionary<string,string> texts = new Dictionary<string,string>();
				
		public bool Contains(string text)
		{
			return texts.ContainsKey(text);
		}
		
		public int Count
		{
			get{ return texts.Count;}
		}
		
		/// <summary>
		/// Add text.
		/// Requires.IsNotNull(newText,"newText");
		///	Requires.That(!Contains(newText),"Not Contains({0})",newText);
		/// Ensures.That(Count > 0,"Count > 0");
		/// </summary>
		/// <param name="newText">The text to be added</param>
		public void AddText(string newText)
		{
			Requires.IsNotNull(newText,"newText");
			Requires.That(!Contains(newText),"Not Contains({0})",newText);
			
			texts.Add(newText,newText);
			
			Ensures.That(Count > 0,"Count > 0");
		}
		
	}
}